import { Injectable } from '@angular/core';
import {RequestUtil} from "../../../util/request-util";
import {API} from "../../../constants/constants";
import {Observable} from "rxjs";
import {MsgResult} from "../../../models/msg-result";

@Injectable()
export class DemarcatesService {

  constructor(
    private requestUtil : RequestUtil
  ) { }

  /**
   * 获取行政区划关联树
   * @returns {Observable<MsgResult>|any}
   */
  getRetrieveRegionsTree(): Observable<MsgResult> {
    return this.requestUtil.get(API.getRetrieveRegionsTree);
  }
  getPoint(demarcate) :  Observable<MsgResult> {
    let params = "regionCode="+demarcate.regionCode+"&siteType="+demarcate.siteType+"&siteName="+demarcate.siteName+"&siteCategory="+demarcate.siteCategory;
    return this.requestUtil.get(API.getPointDetail,params);
  }
  postPoint (demarcate) :  Observable<MsgResult> {
    console.log(demarcate);
    let params = "siteCode="+demarcate.demarcateId+"&latitude="+demarcate.demarcateLat+"&longitude="+demarcate.demarcateLng;
    return this.requestUtil.post(API.postPointDetail,params);
  }
}
